package bounce;

import java.awt.Color;

/**
 * Class to represent a rectangle that can be filled with colour
 * 
 * @author Ken Neth Yeoh
 *
 */

public class DynamicRectangleShape extends Shape {
	
	private Color colour;
	private boolean isSolid = false;
	
	public DynamicRectangleShape(int x, int y, int deltaX, int deltaY, int width, int height, Color colour) {
		super(x, y, deltaX, deltaY, width, height);
		this.colour = colour;
	}

	@Override
	public void paint(Painter painter) {
		painter.drawRect(fX, fY, fWidth, fHeight);
		if(isSolid) {
			Color currentColor = painter.getColor();
			painter.setColor(colour);
			painter.fillRect(fX, fY, fWidth, fHeight);
			painter.setColor(currentColor);
		}
	}
	
	public void bounce(int direction) {
		switch(direction) {
		case VERTICAL:
			isSolid = true;
			fDeltaX = -fDeltaX;
			break;
		case HORIZONTAL:
			isSolid = false;
			fDeltaY = -fDeltaY;
			break;
		}
	}
}
